/**
 * Copyright (C) 2014 Luvina Software Company
 * UserLogicImpl.java, Dec 15, 2014, Nguyen Huu Luan LA11_AM
 *
 */
package net.luvina.manageuser.logics.impl;

import java.util.ArrayList;
import java.util.List;

import net.luvina.manageuser.dao.impl.TblUserDaoImpl;
import net.luvina.manageuser.entities.TblUser;
import net.luvina.manageuser.entities.UserInfor;
import net.luvina.manageuser.logics.TblUserLogic;

/**
 * Thực thi giao diện TblUserLogic.
 * 
 * @author luan
 * 
 */
public class TblUserLogicImpl implements TblUserLogic {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * manageuser.logics.UserLogic#getListUsers(manageuser.entities.TblUser,
	 * int, int)
	 */
	public List<UserInfor> getListUsers(int offset, int limit, int groupId,
			String fullName, String sortType, String sortByFullName,
			String sortByCodeLevel, String sortByEndDate) {

		TblUserDaoImpl userDao = new TblUserDaoImpl();

		List<UserInfor> lsUsers = userDao.getListUsers(offset, limit, groupId,
				fullName, sortType, sortByFullName, sortByCodeLevel,
				sortByEndDate);

		return lsUsers;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * manageuser.logics.UserLogic#getTotalUsers(manageuser.entities.TblUser)
	 */
	public int getTotalRecords(int groupId, String fullName) {
		TblUserDaoImpl userDao = new TblUserDaoImpl();
		int totalRecords = userDao.getTotalUsers(groupId, fullName);
		return totalRecords;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.luvina.manageuser.logics.TblUserLogic#getListLoginName()
	 */
	public List<String> getListLoginName() {
		List<String> listLoginName = new ArrayList<String>();
		List<TblUser> listTblUser = new ArrayList<TblUser>();
		TblUserDaoImpl userDao = new TblUserDaoImpl();
		listTblUser = userDao.getSpecificInfoOfAllUser();
		for (TblUser user : listTblUser) {
			listLoginName.add(user.getLoginName());
		}
		return listLoginName;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.luvina.manageuser.logics.TblUserLogic#getListEmail()
	 */
	public List<String> getListEmail() {
		List<String> listEmail = new ArrayList<String>();
		List<TblUser> listTblUser = new ArrayList<TblUser>();
		TblUserDaoImpl userDao = new TblUserDaoImpl();
		listTblUser = userDao.getSpecificInfoOfAllUser();
		for (TblUser user : listTblUser) {
			listEmail.add(user.getEmail());
		}
		return listEmail;
	}

}
